package lovo01.lesson06;

import javax.swing.*;
import java.util.List;

/**
 * 窗口
 */
public class PukeFrame extends JFrame {

    private DouDiZhu douDiZhu = new DouDiZhu();
    private ImageIcon player1 = new ImageIcon("images/player01.jpg");
    private ImageIcon player2 = new ImageIcon("images/player02.jpg");
    private ImageIcon player3 = new ImageIcon("images/player03.jpg");

    public PukeFrame(){
        this.setLayout(null);

        List<PuKe> playOne = douDiZhu.getPlayer1();
        for (int i = 0;i < playOne.size();i++){
            PuKe puKe = playOne.get(i);
            JLabel puLabel = new JLabel(new ImageIcon("images/" + (puKe.getPointValue() + 3)
                    + "_" + (puKe.getTypeValue() + 1) + ".jpg"));
            puLabel.setBounds(100, (playOne.size() - i - 1) * 30,105,150);
            this.add(puLabel);
        }

        List<PuKe> playTwo = douDiZhu.getPlayer2();
        for (int i = 0;i < playTwo.size();i++){
            PuKe puKe = playTwo.get(i);
            JLabel puLabel = new JLabel(new ImageIcon("images/" + (puKe.getPointValue() + 3) + "_"
            + (puKe.getTypeValue() + 1) + ".jpg"));
            puLabel.setBounds(280 + (playTwo.size() - i - 1) * 30,500,105,150);
            this.add(puLabel);
        }

        List<PuKe> playThree = douDiZhu.getPlayer3();
        for (int i = 0;i < playThree.size();i++){
            PuKe puKe = playThree.get(i);
            JLabel puLabel = new JLabel(new ImageIcon("images/" + (puKe.getPointValue() + 3) + "_"
                    + (puKe.getTypeValue() + 1) + ".jpg"));
            puLabel.setBounds(1000,(playOne.size() - i - 1) * 30,105,150);
            this.add(puLabel);
        }

        List<PuKe> baseCard = douDiZhu.getCardHand();
        for (int i = 0;i < baseCard.size();i++){
            PuKe puKe = baseCard.get(i);
            JLabel puLabel = new JLabel(new ImageIcon("images/" + (puKe.getPointValue() + 3) + "_"
                    + (puKe.getTypeValue() + 1) + ".jpg"));
            puLabel.setBounds(480 + (baseCard.size() - i - 1) * 30,100,105,150);
            this.add(puLabel);
        }



        //头像布局
        JLabel pukeLabel = new JLabel(player1);
        pukeLabel.setBounds(30,50,50,50);
        this.add(pukeLabel);
        JLabel pukeLabel2 = new JLabel(player2);
        pukeLabel2.setBounds(550,700,50,50);
        this.add(pukeLabel2);
        JLabel pukeLabel3 = new JLabel(player3);
        pukeLabel3.setBounds(1100,50,50,50);
        this.add(pukeLabel3);


        this.setSize(1200,800);
        this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        this.setLocationRelativeTo(null);
        this.setVisible(true);
    }

    public static void main(String[] args) {
        new PukeFrame();
    }
}
